package com.atguigu.day17_1.test05;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author fenge
 */
public class Test05 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HashMap<Integer,String> hashMap = new HashMap<>();
        hashMap.put(1930,"乌拉圭");
        hashMap.put(1934,"意大利");
        hashMap.put(1938,"意大利");
        hashMap.put(1950,"乌拉圭");
        hashMap.put(1954,"西德");
        hashMap.put(1958,"巴西");
        hashMap.put(1962,"巴西");
        hashMap.put(1966,"英格兰");
        hashMap.put(1970,"巴西");
        hashMap.put(1974,"西德");
        hashMap.put(1978,"阿根廷");
        hashMap.put(1982,"意大利");
        hashMap.put(1986,"阿根廷");
        System.out.println("请输入一个年份:");
        int year = scanner.nextInt();
        for (Map.Entry<Integer, String> integerStringEntry : hashMap.entrySet()) {
            if (year==integerStringEntry.getKey()){
                System.out.println(year+"年:获得世界冠军的是:"+integerStringEntry.getValue());
            }
        }
        System.out.println("请输入一个国家名称:");
        String string = scanner.next();
        System.out.println("该国球队在如下年份获得过冠军:");
        for (Map.Entry<Integer, String> integerStringEntry : hashMap.entrySet()) {
            if (string.equals(integerStringEntry.getValue())){
                System.out.println(integerStringEntry.getKey());
            }
        }
    }
}
